package com.platform.enums;

/**
 * Description: 连接类型
 *
 * @author zyk
 */
public enum LinkType {
    MySql5("MySQL5.x.x","MySql",DirExNodeType.RDBMS),
    MySql8("MySQL8.x.x","MySql",DirExNodeType.RDBMS),
    GBase("GBase", "GBase",DirExNodeType.RDBMS),
    Oracle("Oracle","Oracle",DirExNodeType.RDBMS),
    SqlServer("SQL Server","SqlServer",DirExNodeType.RDBMS),
    PostgreSQL("PostgreSQL","PostgreSQL",DirExNodeType.RDBMS),
    ClickHouse("ClickHouse","ClickHouse",DirExNodeType.MPP),
    Greenplum("Greenplum","Greenplum",DirExNodeType.MPP),
    FTP("FTP","FTP",DirExNodeType.FTP),
    SFTP("SFTP","SFTP",DirExNodeType.FTP);

    private String name;

    private String oldName;

    private DirExNodeType nodeType;

    public static LinkType value(String type){
        for(LinkType dbType : LinkType.values()){
            if(dbType.getName().equalsIgnoreCase(type)
                    || dbType.getOldName().equalsIgnoreCase(type)){
                return dbType;
            }
        }
        return null;
    }

    LinkType(String name, String oldName) {
        this.name = name;
        this.oldName = oldName;
    }

    LinkType(String name, String oldName, DirExNodeType nodeType) {
        this.name = name;
        this.oldName = oldName;
        this.nodeType = nodeType;
    }

    public static String getQuotesLinkType(String linkType) {
        String quote = "";
        switch (LinkType.value(linkType)) {
            //case PostgreSQL:
            case Greenplum:
            case SqlServer:
            case Oracle:
                quote = "\"";
                break;
            case ClickHouse:
            case MySql5:
            case MySql8:
            case GBase:
                quote = "`";
                break;
            default:
                break;
        }
        return quote;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getOldName() {
        return oldName;
    }

    public void setOldName(String oldName) {
        this.oldName = oldName;
    }

    public DirExNodeType getNodeType() {
        return nodeType;
    }

    public void setNodeType(DirExNodeType nodeType) {
        this.nodeType = nodeType;
    }
}
